_ostree_kernel_args_replace_take: don't leak when replacing
authorSimon McVittie <smcv@debian.org>
Sat, 29 Oct 2016 20:31:18 +0000 (21:31 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Sun, 30 Oct 2016 21:37:37 +0000 (21:37 +0000)
commite757f736e7f363f1fd03cb6b198f96888d31ad18
tree4cb29ba1546c8ae09cf19867d8f25ef9ef46b8b7
parenta0e7d411c11c41f81321b463c53722e746334012
_ostree_kernel_args_replace_take: don't leak when replacing

If !existed, then we add arg to kargs->order, where it will be freed
by that array's free-function. However, if the kernel argument did
already exist, we have to either free arg ourselves (and make sure
the old key is what appears in the hash table), or do a linear search
on kargs->order to replace the old key with the new.

Leak found by valgrind memcheck.

Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #559
Approved by: cgwalters
src/libostree/ostree-kernel-args.c